package com.wfs.suanfa.test;


import java.util.Objects;

/**
 * @author: wfs
 * @Date: 2020/11/21 15:08
 * @Description:
 */
public class T {
    public static void main(String[] args) {
        System.out.println("777083181883633".hashCode()%4);
        System.out.println("777083181883633".hashCode()%64);
    }

    public static int minKBitFlips(int[] A, int K) {
        if (K > A.length || K<=0 ||A ==null ||A.length==0) {
            return -1;
        }
        int count = 0;
        for (int i = 0; i < A.length; i++) {
            int index = i + K - 1;
            //判断 index下标是否大于数据长度
            if (index >= A.length) {
                //判断下面
                if (A[i] == 0) {
                    return -1;
                }
            }
            boolean temp = true;
            for (int i1 = i; i1 <= index; i1++) {
                if (A[i] == 1 && temp) {
                    //不反转
                } else {
                    count += temp ? 1 : 0;
                    temp = false;
                    A[i1] = Objects.equals(A[i1], 1) ? 0 : 1;
                    //其他关联下标也全部反转
                }
            }
            if (A[i] == 0) {
                return -1;
            }
        }
        return count;
    }

}
